//Yet to be completed
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import org.junit.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.io.*;

public class filedownload {

	@Test
	public void sample() throws InterruptedException{
		
	
		File profileDir = new File("C:/Users/home/AppData/Roaming/Mozilla/Firefox/Profiles/upi78mth.default");
		FirefoxProfile profile = new FirefoxProfile(profileDir);
		WebDriver driver = new FirefoxDriver(profile);
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		driver.get("http://www.messenger.yahoo.com/");
		String sourcelocation = driver.findElement(By.id("messenger-download")).getAttribute("href");
		String wget_command = "cmd /c wget -P d:" + sourcelocation;
		try {
			Process exec = Runtime.getRuntime().exec(wget_command);
			int exitVal = exec.waitFor();
			System.out.println("Exit value: " + exitVal);
	} catch(IOException ex){
			System.out.println(ex.toString());
		}	
		
		driver.quit();	
}
}